

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>The prefix module &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="../index.html" />
    <link rel="up" title="The logging module" href="mod_pyamp_logging.html" />
    <link rel="next" title="The loggable module" href="pyamp_logging_loggable.html" />
    <link rel="prev" title="The logger module" href="pyamp_logging_logger.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="pyamp_logging_loggable.html" title="The loggable module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="pyamp_logging_logger.html" title="The logger module"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="mod_pyamp.html" >The pyamp module</a> &raquo;</li>
          <li><a href="mod_pyamp_logging.html" accesskey="U">The logging module</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pyamp.logging.prefix">
<span id="the-prefix-module"></span><h1>The prefix module<a class="headerlink" href="#module-pyamp.logging.prefix" title="Permalink to this headline">¶</a></h1>
<p>The prefix module contains the Prefix, FnPrefix, and TimePrefix classes.</p>
<p>These classes provide the ability to create specific logging prefixes which
will be printed at the start of a logged message. These prefixes can be things
such as: the output of a specific function, the current time, or custom
prefixes.</p>
<div class="section" id="the-fnprefix-class">
<h2>The FnPrefix class<a class="headerlink" href="#the-fnprefix-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-4b1207b279933c05f608b9e297abfa7f48711049.png" alt="Inheritance diagram of pyamp.logging.prefix.FnPrefix" usemap="#inheritancec7db511f37" class="inheritance"/>
<map id="inheritancec7db511f37" name="inheritancec7db511f37">
<area shape="rect" href="#pyamp.logging.prefix.Prefix" title="pyamp.logging.prefix.Prefix" alt="" coords="13,7,205,33"/>
<area shape="rect" href="#pyamp.logging.prefix.FnPrefix" title="pyamp.logging.prefix.FnPrefix" alt="" coords="5,84,213,111"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.logging.prefix.FnPrefix">
<em class="property">class </em><tt class="descclassname">pyamp.logging.prefix.</tt><tt class="descname">FnPrefix</tt><big>(</big><em>function</em>, <em>color=0</em>, <em>prefix=None</em><big>)</big><a class="reference internal" href="../_modules/pyamp/logging/prefix.html#FnPrefix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.logging.prefix.FnPrefix" title="Permalink to this definition">¶</a></dt>
<dd><p>The FnPrefix class provides to ability to create a <a class="reference internal" href="#pyamp.logging.prefix.Prefix" title="pyamp.logging.prefix.Prefix"><tt class="xref py py-class docutils literal"><span class="pre">Prefix</span></tt></a> whose
text results from calling a specified function when the <a class="reference internal" href="#pyamp.logging.prefix.Prefix" title="pyamp.logging.prefix.Prefix"><tt class="xref py py-class docutils literal"><span class="pre">Prefix</span></tt></a> is
applied to a message.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">prefix</span> <span class="o">=</span> <span class="n">FnPrefix</span><span class="p">(</span><span class="n">function</span><span class="o">=</span><span class="k">lambda</span><span class="p">:</span> <span class="s">&quot;Hey!&quot;</span><span class="p">)</span>

<span class="c"># Prints: [Hey!]: This is the message</span>
<span class="n">prefix</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="s">&quot;This is the message&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>This class can be used to dynamically create the text used for a prefix by
calling a function which returns the desired value for the prefix.</p>
<ul class="simple">
<li>function &#8211; The function which returns the Prefix text</li>
<li>color &#8211; The color in which the Prefix will be displayed</li>
<li>prefix &#8211; The next Prefix in the chain</li>
</ul>
</dd></dl>

</div>
<div class="section" id="the-colors-class">
<h2>The Colors class<a class="headerlink" href="#the-colors-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-9dd78613081a5c84e023b96e7885f2ee084b2319.png" alt="Inheritance diagram of pyamp.logging.prefix.Colors" usemap="#inheritance04b99ad42f" class="inheritance"/>
<map id="inheritance04b99ad42f" name="inheritance04b99ad42f">
<area shape="rect" href="pyamp_logging_colors.html#pyamp.logging.colors.Colors" title="pyamp.logging.colors.Colors" alt="" coords="5,7,205,33"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.logging.prefix.Colors">
<em class="property">class </em><tt class="descclassname">pyamp.logging.prefix.</tt><tt class="descname">Colors</tt><a class="headerlink" href="#pyamp.logging.prefix.Colors" title="Permalink to this definition">¶</a></dt>
<dd><p>The Colors class contains two classes which define possible Foreground
and Background colors. These colors can be used to colorize console output
in a specific way.</p>
<dl class="class">
<dt id="pyamp.logging.prefix.Colors.Background">
<em class="property">class </em><tt class="descname">Background</tt><a class="headerlink" href="#pyamp.logging.prefix.Colors.Background" title="Permalink to this definition">¶</a></dt>
<dd><p>The Background class contains definitions of the following
background colors.</p>
<ul class="simple">
<li><em>White_Bold_Underline</em></li>
<li><em>Blue</em>, and <em>Light_Blue</em></li>
<li><em>Purple</em>, and <em>Light_Purple</em></li>
<li><em>Green</em>, and <em>Light_Green</em></li>
<li><em>Red</em>, and <em>Light_Red</em></li>
<li><em>Gray</em>, and <em>Light_Gray</em></li>
<li><em>Cyan</em>, and <em>Light_Cyan</em></li>
<li><em>Orange</em>, and <em>Light_Yellow</em></li>
</ul>
</dd></dl>

<dl class="class">
<dt id="pyamp.logging.prefix.Colors.Foreground">
<em class="property">class </em><tt class="descclassname">Colors.</tt><tt class="descname">Foreground</tt><a class="headerlink" href="#pyamp.logging.prefix.Colors.Foreground" title="Permalink to this definition">¶</a></dt>
<dd><p>The Foreground class contains definitions of the following
foreground colors.</p>
<ul class="simple">
<li><em>White</em></li>
<li><em>White_Bold</em></li>
<li><em>White_Underline</em></li>
<li><em>Black</em></li>
<li><em>Blue</em>, and <em>Light_Blue</em></li>
<li><em>Purple</em>, and <em>Light_Purple</em></li>
<li><em>Green</em>, and <em>Light_Green</em></li>
<li><em>Red</em>, and <em>Light_Red</em></li>
<li><em>Gray</em>, and <em>Light_Gray</em></li>
<li><em>Cyan</em>, and <em>Light_Cyan</em></li>
<li><em>Orange</em>, and <em>Light_Yellow</em></li>
</ul>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="the-prefix-class">
<h2>The Prefix class<a class="headerlink" href="#the-prefix-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-dba2db4f2ed97135132e726af6db1fc2d0032ee0.png" alt="Inheritance diagram of pyamp.logging.prefix.Prefix" usemap="#inheritance0847ded4b4" class="inheritance"/>
<map id="inheritance0847ded4b4" name="inheritance0847ded4b4">
<area shape="rect" href="#pyamp.logging.prefix.Prefix" title="pyamp.logging.prefix.Prefix" alt="" coords="5,7,197,33"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.logging.prefix.Prefix">
<em class="property">class </em><tt class="descclassname">pyamp.logging.prefix.</tt><tt class="descname">Prefix</tt><big>(</big><em>text=None</em>, <em>color=0</em>, <em>prefix=None</em><big>)</big><a class="reference internal" href="../_modules/pyamp/logging/prefix.html#Prefix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.logging.prefix.Prefix" title="Permalink to this definition">¶</a></dt>
<dd><p>The Prefix class provides the ability to add chain of prefixes to a
message. A Prefix contains text which is printed in square brackets
before the given message. The following shows an example of the a
Prefix for the string &#8220;DEBUG&#8221;.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">prefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">&quot;DEBUG&quot;</span><span class="p">)</span>

<span class="c"># Prints: [DEBUG]: This is the message</span>
<span class="n">prefix</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="s">&quot;This is the message&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>A Prefix can be colored, and it can contain other prefixes which are
appended to the message before adding the current Prefix.</p>
<p>An example of multiple prefixes:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">debugPrefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">&quot;DEBUG&quot;</span><span class="p">)</span>
<span class="n">examplePrefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">&quot;example&quot;</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="n">debugPrefix</span><span class="p">)</span>
<span class="n">datePrefix</span> <span class="o">=</span> <span class="n">Prefix</span><span class="p">(</span><span class="n">text</span><span class="o">=</span><span class="s">&quot;03/11/2012&quot;</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="n">examplePrefix</span><span class="p">)</span>

<span class="c"># Prints: [DEBUG]: [example]: [03/11/2012]: This is the message</span>
<span class="n">datePrefix</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="s">&quot;This is the message&quot;</span><span class="p">)</span>
</pre></div>
</div>
<ul class="simple">
<li>text &#8211; The text to display in the Prefix</li>
<li>color &#8211; The color in which the Prefix will be displayed</li>
<li>prefix &#8211; The next Prefix in the chain</li>
</ul>
<dl class="method">
<dt id="pyamp.logging.prefix.Prefix.apply">
<tt class="descname">apply</tt><big>(</big><em>message</em>, <em>useColors=False</em><big>)</big><a class="reference internal" href="../_modules/pyamp/logging/prefix.html#Prefix.apply"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.logging.prefix.Prefix.apply" title="Permalink to this definition">¶</a></dt>
<dd><p>Apply the chain of Prefixes to the given message.</p>
<ul class="simple">
<li>message &#8211; The message to apply the Prefix chain to</li>
<li>useColors &#8211; True to use colors, False otherwise</li>
</ul>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="the-timeprefix-class">
<h2>The TimePrefix class<a class="headerlink" href="#the-timeprefix-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-ac752e2894364ffd97e30ecded45b949b445ab23.png" alt="Inheritance diagram of pyamp.logging.prefix.TimePrefix" usemap="#inheritance6a6565cf3f" class="inheritance"/>
<map id="inheritance6a6565cf3f" name="inheritance6a6565cf3f">
<area shape="rect" href="#pyamp.logging.prefix.FnPrefix" title="pyamp.logging.prefix.FnPrefix" alt="" coords="13,84,221,111"/>
<area shape="rect" href="#pyamp.logging.prefix.TimePrefix" title="pyamp.logging.prefix.TimePrefix" alt="" coords="5,161,229,188"/>
<area shape="rect" href="#pyamp.logging.prefix.Prefix" title="pyamp.logging.prefix.Prefix" alt="" coords="21,7,213,33"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.logging.prefix.TimePrefix">
<em class="property">class </em><tt class="descclassname">pyamp.logging.prefix.</tt><tt class="descname">TimePrefix</tt><big>(</big><em>format=None</em>, <em>color=0</em>, <em>prefix=None</em><big>)</big><a class="reference internal" href="../_modules/pyamp/logging/prefix.html#TimePrefix"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.logging.prefix.TimePrefix" title="Permalink to this definition">¶</a></dt>
<dd><p>The TimePrefix provides the ability to add a <a class="reference internal" href="#pyamp.logging.prefix.Prefix" title="pyamp.logging.prefix.Prefix"><tt class="xref py py-class docutils literal"><span class="pre">Prefix</span></tt></a> which
displays the date and or time when the <a class="reference internal" href="#pyamp.logging.prefix.Prefix" title="pyamp.logging.prefix.Prefix"><tt class="xref py py-class docutils literal"><span class="pre">Prefix</span></tt></a> is applied to the
message in a specified format.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">prefix</span> <span class="o">=</span> <span class="n">TimePrefix</span><span class="p">(</span><span class="n">format</span><span class="o">=</span><span class="s">&quot;%Y-%m-</span><span class="si">%d</span><span class="s">&quot;</span><span class="p">)</span>

<span class="c"># Prints: [2012-03-22]: This is the message</span>
<span class="n">prefix</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="s">&quot;This is the message&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>This class is useful for dynamically timestamping logged messages so they
can easily be tracked in the system output.</p>
<ul>
<li><dl class="first docutils">
<dt>format &#8211; The format in which the time will be displayed. See the</dt>
<dd><p class="first last">man page for &#8216;date&#8217;</p>
</dd>
</dl>
</li>
<li><p class="first">color &#8211; The color in which the Prefix will be displayed</p>
</li>
<li><p class="first">prefix &#8211; The next prefix in the chain</p>
</li>
</ul>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">The prefix module</a><ul>
<li><a class="reference internal" href="#the-fnprefix-class">The FnPrefix class</a></li>
<li><a class="reference internal" href="#the-colors-class">The Colors class</a></li>
<li><a class="reference internal" href="#the-prefix-class">The Prefix class</a></li>
<li><a class="reference internal" href="#the-timeprefix-class">The TimePrefix class</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="pyamp_logging_logger.html"
                        title="previous chapter">The logger module</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="pyamp_logging_loggable.html"
                        title="next chapter">The loggable module</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/_generated/pyamp_logging_prefix.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="pyamp_logging_loggable.html" title="The loggable module"
             >next</a> |</li>
        <li class="right" >
          <a href="pyamp_logging_logger.html" title="The logger module"
             >previous</a> |</li>
        <li><a href="../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="mod_pyamp.html" >The pyamp module</a> &raquo;</li>
          <li><a href="mod_pyamp_logging.html" >The logging module</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>